from django.db import models

# Create your models here.
class Buyer(models.Model):
    """卖家实体类"""
    name = models.CharField(max_length=64, unique=True) # 用户名
    password = models.CharField(max_length=64) # 密码
    email = models.EmailField(null=True) # 邮箱
    phone = models.CharField(max_length=11, null=True) # 电话
    address = models.CharField(max_length=32, null=True) # 地址

    def __str__(self):
        return self.name

    class Meta:
        db_table = "buyer"


class Receiver(models.Model):
    """收件人实体类"""
    name = models.CharField(max_length=64) # 姓名
    phone = models.CharField(max_length=64, null=True) # 电话
    postcode = models.CharField(max_length=64, null=True) # 邮编
    address = models.CharField(max_length=64, null=True) # 地址
    isdefault = models.BooleanField(default=1, null=True) # 是否为默认收获地址
    buyer = models.ForeignKey(to=Buyer, on_delete=models.CASCADE, null=True) # 所属买家

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'reveiver'